package com.example.utils;

import com.alibaba.fastjson.JSONObject;
import com.example.utils.common.Constant;

public class LoginUtil {
    public static String login(String jsonStr,String refreshTokenExpireTime){
        if (RedisUtil.exists(Constant.PREFIX_SHIRO_CACHE + jsonStr)) {
            RedisUtil.delete(Constant.PREFIX_SHIRO_CACHE + jsonStr);
        }
        String currentTimeMillis = String.valueOf(System.currentTimeMillis());
        RedisUtil.set(Constant.PREFIX_SHIRO_REFRESH_TOKEN + jsonStr, currentTimeMillis, Integer.parseInt(refreshTokenExpireTime));
        String token = JwtUtil.sign(jsonStr, currentTimeMillis);
        return token;
    }
}
